package com.hdw.job.service;

import com.hdw.common.base.mapper.BaseMapper;
import com.hdw.job.bean.vo.DimQryVO;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by liujunlei on 2021/7/19.
 */
@Service
public class EtlCommonServiceImpl{

    @Autowired
    BaseMapper baseMapper;

    public List<Map<String, Object>> dimPubQuery(DimQryVO dimQryVO) {
        String sql = "select id,cd,na from "+dimQryVO.getTableName();
        return baseMapper.findBySql(sql);
    }

    public JobParametersBuilder addOrgJobParameter(JobParametersBuilder parametersBuilder) {
        DimQryVO dimQryVO = new DimQryVO();
        dimQryVO.setTableName("md_dim_org");
        List<Map<String, Object>> orgList = dimPubQuery(dimQryVO);
        for(Map<String, Object> map:orgList) {
            parametersBuilder.addString(map.get("cd").toString(),map.get("id").toString());
        }
        return parametersBuilder;
    }
}
